<template>
    <div>
        <Modules v-if="kanban.id" :projectId="kanban.id">
        </Modules>

        <el-dialog  title="提示":visible.sync="isAddingModule" :close-on-click-modal="false">
            <el-form ref="form" label-width="80px">
                <el-form-item label="活动名称">
                    <el-input v-model="moduleName"></el-input>
                </el-form-item>
                <el-form-item style="margin-top: 80px">
                    <el-button type="primary" @click="addModule">确 定</el-button>
                    <el-button @click="isAddingModule = false">取 消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>

        <el-button type="primary" @click="isAddingModule = true" icon="el-icon-push">新建模块</el-button>
    </div>

</template>

<script>
    import Modules from '../../components/Modules.vue'
    import moduleService from '../../biz/api/moduleService'
    import myService from '../../biz/api/myService'

    export default {
        components: {
            Modules,
        },
        data () {
            return {
                //创建Module
                isAddingModule: false,
                //moduleName
                moduleName: '',
                //默认看板
                kanban: {}
            }
        },
        methods: {
            addModule(){
                moduleService.addModule(this.moduleName);
                this.moduleName = ''
                this.isAddingModule = false
            }
        },
        computed: {
        },
        async mounted(){
            try{
                //获得看板
                this.kanban = await myService.defaultKanban()
            } catch (e){
                this.$handleError(e, '获取默认看板失败', true)
            }
        }
    }
</script>

<style>
</style>
